<?php
defined('BY_JYA') or exit('error');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'edit';
$return=array();

if($_RQ['op']=='edit'){
	$item=pdo_get('core_account_product_biaoqian',array('uniacid'=>$_SESSION['uniacid']));
	$return['item']=$item;
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'desc'=>'标签',
		'tabs'=>array(
			'1'=>array('op'=>'edit','title'=>'标签'),
		),
		'edit'=>array(
			'0'=>array('type'=>'text','title'=>'标签','name'=>'bqs', 'help'=>'填写多个标签，以空格分开！' ),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	$item=pdo_get('core_account_product_biaoqian',array('uniacid'=>$_SESSION['uniacid']));
	$data=array(
		'bqs'=>$postdata['bqs']
	);
	if($item){
		pdo_update('core_account_product_biaoqian',$data,array('uniacid'=>$_SESSION['uniacid']));
		exi('产品标签修改成功！');
	}else{
		$data['uniacid']=$_SESSION['uniacid'];
		pdo_insert('core_account_product_biaoqian',$data);
		exi('产品标签增加成功！');
	}
}

if($_RQ['op'] == 'del'){
	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('core_account_product_biaoqian',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('core_account_product_biaoqian',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
			}
		}
	}
	exi('删除成功！');
}

?>